using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Core;
using NUnit.Framework;
using Tests;

namespace Madason.Templates.DAO.Tests
{
	[TestFixture]
	public class TestStateMachine
	{
		[Test]
		public void TestInitialState()
		{
			TestEntity entity = TestEntity.GetInstance();

			Assert.AreEqual(TestEntity.StateMachine1Enum.FirstState, entity.StateMachine1);
		}

		[Test]
		public void TestTransisiton()
		{
			TestEntity entity = TestEntity.GetInstance();

			Assert.AreEqual(TestEntity.StateMachine1Enum.FirstState, entity.StateMachine1);
			entity.GoSecond();
			Assert.AreEqual(TestEntity.StateMachine1Enum.SecondState, entity.StateMachine1);
			entity.GoThird();
			Assert.AreEqual(TestEntity.StateMachine1Enum.ThirdState, entity.StateMachine1);
			entity.GoSecond();
			Assert.AreEqual(TestEntity.StateMachine1Enum.SecondState, entity.StateMachine1);
		}

		[Test]
		public void TestStateEvents()
		{
			TestEntityImpl entity = TestEntity.GetInstance() as TestEntityImpl;

			Assert.AreEqual(TestEntity.StateMachine1Enum.FirstState, entity.StateMachine1);
			Assert.AreEqual(false, entity.SecondReachedWasCalled);
			entity.GoSecond();
			Assert.AreEqual(true, entity.SecondReachedWasCalled);
			Assert.AreEqual(false, entity.Effect1Called);
			entity.GoThird();
			Assert.AreEqual(true, entity.Effect1Called);
		}
	}
}
